fix: no need to create compiler instance when closing compiler#11923
Merged
chenjiahan merged 3 commits intomainfrom Oct 20, 2025
Merged
fix: no need to create compiler instance when closing compiler#11923chenjiahan merged 3 commits intomainfrom
chenjiahan merged 3 commits intomainfrom
Conversation
✅ Deploy Preview for rspack canceled.
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR simplifies the Compiler.close() method by using optional chaining to close the compiler instance rather than fetching it through #getInstance(), which prevents unnecessary instance creation and duplicate error logging when the instance doesn't exist.
Key changes:
- Updated
Compiler.close()to usethis.#instance?.close()directly instead of callingthis.#getInstance()followed byinstance!.close() - Added test cases for builtin-swc-loader validation scenarios
Reviewed Changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/rspack/src/Compiler.ts | Simplified close() method to avoid unnecessary instance creation and duplicate error logs |
| tests/rspack-test/configCases/builtin-swc-loader/validate/raw-warning.err | Removed expected error output file |
| tests/rspack-test/configCases/builtin-swc-loader/validate/raw-error.err | Removed expected error output file |
| tests/rspack-test/configCases/builtin-swc-loader/invalid-unknown-option-error/rspack.config.js | Added test configuration for unknown option error handling |
| tests/rspack-test/configCases/builtin-swc-loader/invalid-unknown-option-error/errors.js | Added expected error assertions for unknown option test |
| tests/rspack-test/configCases/builtin-swc-loader/invalid-option-value-error/index.js | Added test case for invalid option value scenarios |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Contributor
📦 Binary Size-limit
🙈 Size remains the same at 47.67MB |
CodSpeed Performance ReportMerging #11923 will not alter performanceComparing Summary
Footnotes |
LingyuCoder
approved these changes
Oct 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR simplifies the
Compiler.close()method.Use
this.#instance?.close()instead of thethis.#getInstance()method, because if the instance is not created, thethis.#getInstance()method will attempt to create an instance twice and the error logs will be printed twice.Related links
Checklist